package com.wnhz.work.yz.activity.forget;

import android.content.Intent;
import android.os.Bundle;
import android.text.SpannableString;
import android.text.Spanned;
import android.text.style.ForegroundColorSpan;
import android.view.View;
import android.widget.TextView;

import com.wnhz.work.yz.BaseActivity;
import com.wnhz.work.yz.R;
import com.wnhz.work.yz.activity.LoginNewActivity;

public class ForgetPassword4Activity extends BaseActivity implements View.OnClickListener {
    private String phone;
    private TextView tv_phone;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_forget_password4);

        initData();
        initView();
    }

    private void initData() {
        phone = getIntent().getStringExtra("phone");
    }

    private void initView() {
        tv_phone = (TextView) findViewById(R.id.tv_phone);
        findViewById(R.id.tv_login).setOnClickListener(this);

        tv_phone.setText(setSpannableString("您已经将 ", phone, " 的密码成功修改。"));
    }

    @Override
    public void onClick(View v) {
        Intent intent;
        switch (v.getId()) {
            //登入
            case R.id.tv_login:
                intent = new Intent(this, LoginNewActivity.class);
                startActivity(intent);
                break;

            default:
                break;
        }
    }

    /**
     * 更改字体
     *
     * @return
     */
    public SpannableString setSpannableString(String s1, String s2, String s3) {
        StringBuilder builder = new StringBuilder();
        builder.append(s1);
        builder.append(s2);
        builder.append(s3);
        SpannableString member = new SpannableString(builder);
//        member.setSpan(new RelativeSizeSpan(0.8f), 0, 1, Spannable.SPAN_INCLUSIVE_EXCLUSIVE);
//        member.setSpan(new RelativeSizeSpan(0.8f), builder.length() - s2.length(), builder.length(),
//                Spannable.SPAN_INCLUSIVE_EXCLUSIVE);
        member.setSpan(new ForegroundColorSpan(getResources().getColor(R.color.main_color)), s1.length(), builder.length() - s3.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
        return member;
    }
}
